
#include "Serializer.h"

using namespace ttg;
using namespace ttg::extras::serialization;

//------------------
//--- Serializer ---
//------------------

void Serializer::serializeString(const char *value, const char *name)
{
	if (value == NULL)
	{
		serializeInt(-1, name);
	}
	else
	{
		size_t len = strlen(value);
		serializeInt((int)len, name);
		serializeMemory(value, len, name);
	}
}

void Serializer::serializeObject(structures::SerializableObject *object, const char *name)
{
	serializeReferenceStart(object == NULL, name);
	if (object != NULL)
		object->serialize(*this);
	serializeReferenceEnd();
}
